package com.shenbianyun.cloudcaring;

import com.alibaba.fastjson.JSONObject;
import com.shenbianyun.bosskgpay.constant.MerInfoConstant;
import com.shenbianyun.bosskgpay.utils.DESEncryption;
import com.shenbianyun.bosskgpay.utils.HttpClientHelper;
import okhttp3.*;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @author ：张一凡
 * @date ：2025年05月07日 19:51:05
 * @description：
 */
public class PayTest {

    public final String CHARSET_UTF_8 = "UTF-8";

    // ======================   测试    ======================



    // ======================   生产    ======================


    public static void main(String[] args) {
        try {
            PayTest payTest = new PayTest();
            System.out.println(payTest.payTest());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public String payTest() throws Exception {

        String url = "https://testhuibutie-h5.serviceshare.com/mp/appOrder/confirmPay";
        Map<String, String> map = new HashMap<>();
        map.put("s", "3c85a6f2d992a71de42dca42772ff37e.0");
        map.put("packageId", "18888888888");
        map.put("tradeType", "H5");
        map.put("quotaPayAmt", "0.01");
        map.put("zfbPayAmt", "0");
        map.put("wxPayAmt", "0");
        map.put("payType", "POINTS");
        String s = DESEncryption.encryptPassword("111111");
        map.put("payPassword", s);
        map.put("settleAmt", "0.01");

        String requestBody = JSONObject.toJSONString(map);
        //发送请求
        String resData = HttpClientHelper.sendPost3(url, "application/json", requestBody, "POST", CHARSET_UTF_8,"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyUm9sZSI6Ikh1aUJ1VGllIiwiZXhwIjoxNzQ2NTI2NDkyLCJ1c2VybmFtZSI6IjEzMjEzIn0.sgbELlNwKvh9oqAaPPE469ceO4wm4JHZ1cWnSq9bmnw");
        System.out.println("响应数据：" + resData);

        return resData;
        //OkHttpClient client = new OkHttpClient.Builder().connectTimeout(10, TimeUnit.SECONDS)
        //        //设置连接超时时间
        //        .readTimeout(20, TimeUnit.SECONDS)//设置读取超时时间
        //        .build();
        //// 创建请求体
        //MediaType mediaType = MediaType.parse("application/json");
        //String requestBody = JSONObject.toJSONString(map);
        //RequestBody body = RequestBody.create(mediaType, requestBody);
        //// 创建POST请求
        //Request request = new Request.Builder().url(url).post(body).header("token",getToken()).build();
        //Response response = client.newCall(request).execute();
        //if (response.isSuccessful()) {
        //    String responseBody = response.body().string();
        //    JSONObject rawResult = JSONObject.parseObject(responseBody, JSONObject.class);
        //    System.out.println(rawResult);
        //} else {
        //    throw new IOException("请求失败：" + response);
        //}
    }
}
